package com.ruoyi.web.controller.monitorpoint;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yanjing.domain.MonitorPoint;
import com.ruoyi.yanjing.service.IMonitorPointService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 监测点位信息Controller
 * 
 * @author whz
 * @date 2024-11-18
 */
@RestController
@RequestMapping("/yanjing/point")
public class MonitorPointController extends BaseController
{
    @Autowired
    private IMonitorPointService monitorPointService;


    /**
     * 查询监测点位所有信息列表-不分页
     */
    @PreAuthorize("@ss.hasPermi('yanjing:point:selectAllPointList')")
    @GetMapping("/selectAllPointList")
    public AjaxResult selectAllPointList(MonitorPoint monitorPoint)
    {
        return success(monitorPointService.selectMonitorPointList(monitorPoint));
    }

    /**
     * 查询监测点位设备所有信息列表-不分页
     */
    @PreAuthorize("@ss.hasPermi('yanjing:point:selectAllPointDeviceList')")
    @GetMapping("/selectAllPointDeviceList")
    public AjaxResult selectAllPointDeviceList(MonitorPoint monitorPoint)
    {
        return success(monitorPointService.selectAllPointDeviceList(monitorPoint));
    }

    /**
     * 查询监测点位线路电杆信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:point:selectMonitorPointAndLinePoleInfoList')")
    @GetMapping("/selectMonitorPointAndLinePoleInfoList")
    public TableDataInfo selectMonitorPointAndLinePoleInfoList(MonitorPoint monitorPoint)
    {
        startPage();
        List<MonitorPoint> list = monitorPointService.selectMonitorPointAndLinePoleInfoList(monitorPoint);
        return getDataTable(list);
    }

    /**
     * 查询监测点位信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:point:list')")
    @GetMapping("/list")
    public TableDataInfo list(MonitorPoint monitorPoint)
    {
        startPage();
        List<MonitorPoint> list = monitorPointService.selectMonitorPointList(monitorPoint);
        return getDataTable(list);
    }

    /**
     * 导出监测点位信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:point:export')")
    @Log(title = "监测点位信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MonitorPoint monitorPoint)
    {
        List<MonitorPoint> list = monitorPointService.selectMonitorPointList(monitorPoint);
        ExcelUtil<MonitorPoint> util = new ExcelUtil<MonitorPoint>(MonitorPoint.class);
        util.exportExcel(response, list, "监测点位信息数据");
    }

    /**
     * 获取监测点位信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:point:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(monitorPointService.selectMonitorPointById(id));
    }

    /**
     * 新增监测点位信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:point:add')")
    @Log(title = "监测点位信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MonitorPoint monitorPoint)
    {
        return toAjax(monitorPointService.insertMonitorPoint(monitorPoint));
    }

    /**
     * 修改监测点位信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:point:edit')")
    @Log(title = "监测点位信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MonitorPoint monitorPoint)
    {
        return toAjax(monitorPointService.updateMonitorPoint(monitorPoint));
    }

    /**
     * 删除监测点位信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:point:remove')")
    @Log(title = "监测点位信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(monitorPointService.deleteMonitorPointByIds(ids));
    }
}
